#include<bits/stdc++.h>
using namespace std;
signed main() {
	int k;
	cin >> k;

	bool flag = 0;
	for (int i = 10000; i <= 30000; i++) {
		int s1 = stoi(to_string(i).substr(0, 3));
		int s2 = stoi(to_string(i).substr(1, 3));
		int s3 = stoi(to_string(i).substr(2, 3));
		if (!(s1 % k || s2 % k || s3 % k)) {
			cout << i << endl;
			flag = 1;
		}
	}
	if (!flag)
		cout << "No";
	return 0;
}
